feat: add X-Permit-Consistent-Update header on facts proxy requests#306
feat: add X-Permit-Consistent-Update header on facts proxy requests#306
Conversation
🔍 Vulnerabilities of
|
| digest | sha256:6434e121c5fcf51c63f670e47555127f5871518f18a378ae720cbf9c4e08d84d |
| vulnerabilities | |
| platform | linux/amd64 |
| size | 214 MB |
| packages | 252 |
📦 Base Image python:3.10-alpine3.22
| also known as |
|
| digest | sha256:c8f94b3bb77e6ea9015ccd091b7f8aec1b1fcbca95159675235d9a93788797cd |
| vulnerabilities |
Description
| ||||||||||||
Description
| ||||||||||||
Description
| ||||||||||||
The backend opal-interface uses this header to skip sending the control-plane delta update back to PDPs, since the PDP already propagates the update via OPAL Server pubsub after a successful facts proxy write. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Move the X-Permit-Consistent-Update header injection behind an explicit is_consistent_update kwarg so the fallback proxy route (forward_remaining_requests) does not falsely mark generic passthrough requests as consistent updates. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
af90b4f to
74bf9ed
Compare
There was a problem hiding this comment.
Pull request overview
Adds an opt-in request header to facts-service proxy calls made via the “wait-for-local-sync” path, allowing the backend to skip emitting a redundant control-plane delta update when the PDP is already publishing an OPAL pubsub update.
Changes:
- Introduce
CONSISTENT_UPDATE_HEADERand anis_consistent_updatekwarg onFactsClient.build_forward_request()/send_forward_request(), addingX-Permit-Consistent-Update: truewhen enabled. - Set
is_consistent_update=Truefor the consistent-update proxy flow (forward_request_then_wait_for_update). - Add unit tests asserting the header is present when requested and absent by default.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
horizon/facts/client.py |
Adds the consistent-update header constant and gating logic in forwarded request construction/sending. |
horizon/facts/router.py |
Enables the consistent-update header for the wait-for-local-sync proxy flow. |
horizon/tests/test_facts_client.py |
Adds tests covering header inclusion/exclusion behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Address review feedback on PR #306: - Extract CONSISTENT_UPDATE_HEADER_VALUE constant for the "true" literal - Replace tautological constant test with literal-header-spelling assertion - Add send_forward_request kwarg passthrough test - Add router-level tests pinning is_consistent_update on wait-for-update path and asserting the fallback proxy does not set the header Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Summary
X-Permit-Consistent-Update: trueheader on facts requests that the PDP proxies throughforward_request_then_wait_for_update(the wait-for-local-sync flow)forward_remaining_requests) does NOT set the header, so generic passthrough requests continue to rely on the standard control-plane delta pathDetails
The header is gated behind a new
is_consistent_update: bool = Falsekwarg onFactsClient.build_forward_requestandFactsClient.send_forward_request. Onlyforward_request_then_wait_for_update(called by the explicit consistent-update routes: users, tenants, role_assignments, resource_instances, relationship_tuples) passesTrue.Paired with backend changes in permit-backend (branch:
omer/per-14392-consistent-updates-duplicated-updates) which:is_consistent_update: Trueinto the DB session's AMQP headersTest plan
FactsClient.build_forward_request:is_consistent_update=True🤖 Generated with Claude Code